﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IHISCETeim.DAL;
using IHISCETeim.Model;
using IHISCETeim.Library;
using System.Data;

namespace IHISCETeim.BLL
{
    /// <summary>
    /// 收款记录
    /// </summary>
    public class FTradeCatheringController
    {
          /// <summary>
        /// 添加新的　收款记录
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static int Add(FTradeCatheringInfo obj)
        {
            return FTradeCatheringDAL.Add(obj);
        }
        /// <summary>
        /// 删除　收款记录 如果收款记录已冲过帐,则不能删除
        /// </summary>
        /// <param name="FCatheringId"></param>
        /// <returns></returns>
        public static string Delete(int FCatheringId, string remark, decimal DongJieJinE)
        {
            return FTradeCatheringDAL.Delete(FCatheringId, remark, DongJieJinE);
        }
        /// <summary>
        /// 删除　如果收款记录未冲过帐,则能删除
        /// </summary>
        /// <param name="FCatheringId"></param>
        /// <returns></returns>
        public static string DeleteAll(int FCatheringId)
        {
            return FTradeCatheringDAL.DeleteAll(FCatheringId);
        }
        public static FTradeCatheringInfo GetById(int FCatheringId)
        {
            return CBO.FillObject<FTradeCatheringInfo>( FTradeCatheringDAL.GetById(FCatheringId));
        }
        /// <summary>
        /// 根据经销商及状态获取其下可用的所有收款记录 用于下拉列表
        /// </summary>
        /// <param name="JingXiaoShang"></param>
        /// <param name="State">格式为('状态1'，'状态2')</param>
        /// <returns></returns>
        public static List<FTradeCatheringInfo> GetByJingXiaoShang(string JingXiaoShang, string State)
        {
            return CBO.FillCollection<FTradeCatheringInfo>( FTradeCatheringDAL.GetByJingXiaoShang(JingXiaoShang, State));
        }
        public static DataTableCollection GetPagination(string WhereSql, string WhereSql2, int PageIndex, int PageSize, string Sort, ref int TotalCount)
        {
            return FTradeCatheringDAL.GetPagination(WhereSql, WhereSql2,PageIndex, PageSize, Sort, ref  TotalCount);
        }
        public static DataTableCollection GetHistoryPagination(string WhereSql, int PageIndex, int PageSize, string Sort, ref int TotalCount)
        {
            return FTradeCatheringDAL.GetHistoryPagination(WhereSql, PageIndex, PageSize, Sort, ref  TotalCount);
        }
        /// <summary>
        /// 修改　收款记录基本信息如果剩余金额不等于收款金额,则只能改备注信息
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static bool Update(FTradeCatheringInfo obj)
        {
            return FTradeCatheringDAL.Update(obj);
        }
        /// <summary>
        /// 获取每笔收款的最终充值去向 与融资资金走向说明报表 共用
        /// </summary>
        /// <param name="FCatheringId"></param>
        /// <returns></returns>
        public static DataTableCollection GetLastChonZhi(int FCatheringId)
        {
            return FTradeCatheringDAL.GetLastChonZhi(FCatheringId);
        }
         /// <summary>
        /// 获取调帐(系统) 的调帐来源记录
        /// </summary>
        /// <param name="FCatheringId"></param>
        /// <returns></returns>
        public static DataTable GetAdjustingMoneyList(int FCatheringId)
        {
            return FTradeCatheringDAL.GetAdjustingMoneyList(FCatheringId);
        }


         /// <summary>
        ///经销商回款明细表
        /// </summary>
        /// <param name="FCatheringId"></param>
        /// <returns></returns>
        public static DataTable GetHuKunAgentList(string agentsqltemp, string Fdata, string Tdate)
        {
            return FTradeCatheringDAL.GetHuKunAgentList(agentsqltemp,Fdata, Tdate);
        }
        /// <summary>
        /// 获取经销商回款 金额
        /// </summary>
        /// <param name="sqlwhere"></param>
        /// <returns></returns>
        public static object GetHuKunJinE(string sqlwhere)
        {
            return FTradeCatheringDAL.GetHuKunJinE(sqlwhere);
        }
    }
}
